<?php
	class DBMysqlStatement { 
		public $result; 
		public $query; 
		private $dbh; 
		
		public function __construct($dbh, $query) { 
			$this->query = $query; 
			$this->dbh = $dbh; 
			if(!is_resource($dbh)) { 
				throw new Exception("Not a valid database connection"); 
			} 
		} 
		
		public function fetch_row() { 
			if(!$this->result) { 
				throw new Exception("Query not executed"); 
			} 
			return mysql_fetch_row($this->result); 
		} 
		
		public function fetch_assoc() { 
			return mysql_fetch_assoc($this->result); 
		} 
		
		public function num_rows() {
			return mysql_num_rows($this->result);
		}
		
		public function fetchall_assoc() { 
			$result = array();
			 while($row = $this->fetch_assoc()) { 
			 	$result[] = $row; 
			 } 
			 return $result; 
		} 
	}
?>